var gulp = require('gulp');
var less = require('gulp-less');
var cssmin = require('gulp-minify-css');
var babel = require('gulp-babel');
var uglify = require('gulp-uglify');

gulp.task('less', function () {
	gulp.src('src/css/*.less')
		.pipe(less())
		.pipe(gulp.dest('build/css'))
		.pipe(cssmin())
		.pipe(gulp.dest('dist/css'));
});

gulp.task('babel', function () {
	gulp.src('src/js/*.js')
		.pipe(babel({
			presets: ['es2015']
		}))
		.pipe(gulp.dest('build/js'))
		.pipe(uglify())
		.pipe(gulp.dest('dist/js'));
});

gulp.task('watch_less', function () {
	gulp.watch('src/css/*.less', ['less']);
});

gulp.task('watch_babel', function () {
	gulp.watch('src/js/*.js', ['babel']);
});

gulp.task('default', ['watch_less', 'watch_babel']);